package docxlib

// Color allows to set run color
func (r *Run) Color(color string) *Run {
	r.RunProperties.Color = &Color{
		Val: color,
	}

	return r
}

// Size allows to set run size
func (r *Run) Size(size int) *Run {
	r.RunProperties.Size = &Size{
		Val: size * 2,
	}
	return r
}

// 设置文本垂直对齐方式，指定字符间距调整的绝对值（磅为单位）
func (r *Run) Kern(val int) *Run {
	r.RunProperties.Kern = &Kern{
		Val: val,
	}
	return r
}

func (r *Run) Bold() *Run {
	r.RunProperties.Bold = &Bold{}
	return r
}

// 将文本中小写字母转化为大写字母
func (r *Run) SmallCaps() *Run {
	r.RunProperties.SmallCaps = &SmallCaps{}
	return r
}

func (r *Run) Underline(val string) *Run {
	r.RunProperties.Underline = &Underline{
		Val: val,
	}
	return r
}

// 设置文本删除线样式 样式风格选择有：single,double,none
func (r *Run) Strike(val string) *Run {
	r.RunProperties.Strike = &Strike{
		Val: val,
	}
	return r
}

func (r *Run) Highlight(val string) *Run {
	r.RunProperties.Highlight = &Highlight{
		Val: val,
	}
	return r
}

// 设置文本垂直对齐方式，选择方式是：superscript,subscript
func (r *Run) VertAlign(val string) *Run {
	r.RunProperties.VertAlign = &VertAlign{
		Val: val,
	}
	return r
}

// 设置文本的垂直位置,w:val 和 w:relativeFrom 属性一起使用，定义文本的垂直偏移。
func (r *Run) Position(val int,relatieFrom string) *Run {
	r.RunProperties.Positon = &Positon{
		Val: val,
		RelatieFrom: relatieFrom,
	}
	return r
}

func (r *Run) Spacing(val,line,after,before int,lineRule string) *Run {
	r.RunProperties.Spacing = &Spacing{
		Val: val,
		Line: line,
		LineRule: lineRule,
		Before: before,
		After: after,
	}
	return r
}

// AddText adds text to paragraph
func (p *Paragraph) AddText(text string) *Run {
	t := &Text{
		Text: text,
	}

	run := &Run{
		Text:          t,
		RunProperties: &RunProperties{},
	}

	p.Data = append(p.Data, ParagraphChild{Run: run})

	return run
}
